using UnityEngine;
using System.Collections;

public class MousePointerRadius : MonoBehaviour {

	public float radius = 2f;
	
	public bool onlyOnClick = false;
	public bool showCursor = true;
	
	// Use this for initialization
	void Start () {
		if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
			onlyOnClick = true;
		if(!showCursor)
			Screen.showCursor = false;
	}
	
	// Update is called once per frame
	void Update () {
		followMouse();
		mouseOver();
	}
	
	private void followMouse(){
		if(!Input.GetMouseButton (0) && onlyOnClick )
			return;
		Camera mainCamera = Camera.main;
		Ray ray = mainCamera.ScreenPointToRay (Input.mousePosition);
		transform.position =  ray.origin + ray.direction.normalized*radius;
		
		
	}
	
	void OnDestroy(){
		if(!showCursor)
			Screen.showCursor = true;
	}
	
	private void mouseOver(){
		if(showCursor)
			return;

		if (Mouse.isOnButton() ){
			//Screen.showCursor = true;
		}else Screen.showCursor = false;
	}
}
